6A - Triangle - CodeForces Solution


brute force geometry *900

Please click on ads to support us..

Python Code:

import math
x=input().split()
for i in range(0,len(x)):
    x[i]=int(x[i])
x.sort()

a,b,c,d=x[3],x[2],x[1],x[0]

if a<b+c or a<c+d or a<b+d or b<c+d:
    print ("TRIANGLE")
elif a==b+c or a==c+d or a==b+d or b==c+d:
    print("SEGMENT")
else:
    print ("IMPOSSIBLE")

C++ Code:

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int t=1;
   // cin>>t;
    while(t--)
    {

        ll a,b,x,n,d,ans=0;
        ll aa[4];
        set<int>s;
        for(int i=0;i<4;i++)
        {
            cin>>aa[i];
            s.insert(aa[i]);
        }

        sort(aa,aa+4);
        //ll mx=aa[0];

       if(aa[0]+aa[1]>aa[2] || aa[1]+aa[2]>aa[3]|| aa[0]+aa[2]>aa[3])
        {
            cout<<"TRIANGLE"<<endl;
        }
        else if(aa[2]==aa[0]+aa[1] ||  aa[3]==aa[1]+aa[2])
        {
           cout<<"SEGMENT"<<endl;
        }

        else
            cout<<"IMPOSSIBLE"<<endl;
    }
}


Comments

Submit
0 Comments
More Questions

467B - Fedor and New Game
252C - Points on Line
735C - Tennis Championship
992A - Nastya and an Array
554A - Kyoya and Photobooks
79B - Colorful Field
265B - Roadside Trees (Simplified Edition)
1362C - Johnny and Another Rating Drop
1214C - Bad Sequence
1091B - New Year and the Treasure Geolocation
244A - Dividing Orange
1061C - Multiplicity
1312A - Two Regular Polygons
801A - Vicious Keyboard
510B - Fox And Two Dots
616D - Longest k-Good Segment
1604A - Era
555B - Case of Fugitive
551A - GukiZ and Contest
1399F - Yet Another Segments Subset
1371C - A Cookie for You
430B - Balls Game
1263A - Sweet Problem
1332B - Composite Coloring
254A - Cards with Numbers
215A - Bicycle Chain
1288B - Yet Another Meme Problem
1201C - Maximum Median
435A - Queue on Bus Stop
1409B - Minimum Product